/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vera;

import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

/**
 *
 * @author kasia
 */
public class MenuBar extends JMenuBar implements ActionListener {
    
    		public static final long serialVersionUID = 1L;
		public JMenuItem m_menuItemVeraLogOut;
		public JMenuItem m_menuItemVeraExit;
		public JMenu m_menuTitleVera;
		public JMenuItem m_menuItemBillCreate;
		public JMenuItem m_menuItemBillUpdate;
		public JMenuItem m_menuItemBillCancel;
		public JMenuItem m_menuItemBillSearch;
		public JMenuItem m_menuItemBillPrint;
		public JMenu m_menuTitleBill;
		public JMenuItem m_menuItemReceiptCreate;
		public JMenuItem m_menuItemReceiptUpdate;
		public JMenuItem m_menuItemReceiptCancel;
		public JMenuItem m_menuItemReceiptSearch;
		public JMenuItem m_menuItemReceiptPrint;
                public JMenuItem m_menuItemReceiptVariance;
		public JMenu m_menuTitleReceipt;
		public JMenuItem m_menuItemReportRealTime;
		public JMenuItem m_menuItemReportPrevious;
		public JMenu m_menuTitleReport;
		public JMenuItem m_menuItemClientAdd;
		public JMenuItem m_menuItemClientUpdate;
		public JMenuItem m_menuItemClientSearch;
		public JMenu m_menuTitleClient;
		public JMenuItem m_menuItemHelpHelp;
		public JMenuItem m_menuItemHelpAbout;
		public JMenu m_menuTitleHelp;

		public MenuBar() {
			initComponents();
		}

		public void initComponents() {
			add(getMenuTitleVera());
			add(getMenuTitleBill());
			add(getMenuTitleReceipt());
			add(getMenuTitleReport());
			add(getMenuTitleClient());
			add(getMenuTitleHelp());
		}

		public JMenu getMenuTitleHelp() {
			if (m_menuTitleHelp == null) {
				m_menuTitleHelp = new JMenu();
				m_menuTitleHelp.setText(Constants.HELP);
				m_menuTitleHelp.add(getMenuItemHelpHelp());
				m_menuTitleHelp.add(getMenuItemHelpAbout());
			}
			return m_menuTitleHelp;
		}

		public JMenuItem getMenuItemHelpAbout() {
			if (m_menuItemHelpAbout == null) {
				m_menuItemHelpAbout = new JMenuItem();
				m_menuItemHelpAbout.setText(Constants.ABOUT);
			}
			return m_menuItemHelpAbout;
		}

		public JMenuItem getMenuItemHelpHelp() {
			if (m_menuItemHelpHelp == null) {
				m_menuItemHelpHelp = new JMenuItem();
				m_menuItemHelpHelp.setText(Constants.HELP);
			}
			return m_menuItemHelpHelp;
		}

		public JMenu getMenuTitleClient() {
			if (m_menuTitleClient == null) {
				m_menuTitleClient = new JMenu();
				m_menuTitleClient.setText(Constants.CLIENT);
				m_menuTitleClient.add(getMenuItemClientAdd());
				m_menuTitleClient.add(getMenuItemClientUpdate());
				m_menuTitleClient.add(getMenuItemClientSearch());
			}
			return m_menuTitleClient;
		}

		public JMenuItem getMenuItemClientSearch() {
			if (m_menuItemClientSearch == null) {
				m_menuItemClientSearch = new JMenuItem();
				m_menuItemClientSearch.setText(Constants.SEARCH_CLIENT);
			}
			return m_menuItemClientSearch;
		}

		public JMenuItem getMenuItemClientUpdate() {
			if (m_menuItemClientUpdate == null) {
				m_menuItemClientUpdate = new JMenuItem();
				m_menuItemClientUpdate.setText(Constants.UPDATE_CLIENT);
			}
			return m_menuItemClientUpdate;
		}

		public JMenuItem getMenuItemClientAdd() {
			if (m_menuItemClientAdd == null) {
				m_menuItemClientAdd = new JMenuItem();
				m_menuItemClientAdd.setText(Constants.ADD_CLIENT);
			}
			return m_menuItemClientAdd;
		}

		public JMenu getMenuTitleReport() {
			if (m_menuTitleReport == null) {
				m_menuTitleReport = new JMenu();
				m_menuTitleReport.setText(Constants.REPORT);
				m_menuTitleReport.add(getMenuItemReportRealTime());
				m_menuTitleReport.add(getMenuItemReportPrevious());
			}
			return m_menuTitleReport;
		}

		public JMenuItem getMenuItemReportPrevious() {
			if (m_menuItemReportPrevious == null) {
				m_menuItemReportPrevious = new JMenuItem();
				m_menuItemReportPrevious.setText(Constants.PREVIOUS_REPORT);
			}
			return m_menuItemReportPrevious;
		}

		public JMenuItem getMenuItemReportRealTime() {
			if (m_menuItemReportRealTime == null) {
				m_menuItemReportRealTime = new JMenuItem();
				m_menuItemReportRealTime.setText(Constants.REALTIME_REPORT);
			}
			return m_menuItemReportRealTime;
		}

		public JMenu getMenuTitleReceipt() {
			if (m_menuTitleReceipt == null) {
				m_menuTitleReceipt = new JMenu();
				m_menuTitleReceipt.setText(Constants.RECEIPT);
				m_menuTitleReceipt.add(getMenuItemReceiptCreate());
				m_menuTitleReceipt.add(getMenuItemReceiptUpdate());
				m_menuTitleReceipt.add(getMenuItemReceiptCancel());
				m_menuTitleReceipt.add(getMenuItemReceiptSearch());
				m_menuTitleReceipt.add(getMenuItemReceiptPrint());
                                m_menuTitleReceipt.add(getMenuItemReceiptVariance());
			}
			return m_menuTitleReceipt;
		}
                
                public JMenuItem getMenuItemReceiptVariance() {
			if (m_menuItemReceiptVariance == null) {
				m_menuItemReceiptVariance = new JMenuItem();
				m_menuItemReceiptVariance.setText(Constants.ADD_VARIANCE);
			}
			return m_menuItemReceiptVariance;
		}

		public JMenuItem getMenuItemReceiptPrint() {
			if (m_menuItemReceiptPrint == null) {
				m_menuItemReceiptPrint = new JMenuItem();
				m_menuItemReceiptPrint.setText(Constants.PRINT_RECEIPT);
			}
			return m_menuItemReceiptPrint;
		}

		public JMenuItem getMenuItemReceiptSearch() {
			if (m_menuItemReceiptSearch == null) {
				m_menuItemReceiptSearch = new JMenuItem();
				m_menuItemReceiptSearch.setText(Constants.SEARCH_RECEIPT);
			}
			return m_menuItemReceiptSearch;
		}

		public JMenuItem getMenuItemReceiptCancel() {
			if (m_menuItemReceiptCancel == null) {
				m_menuItemReceiptCancel = new JMenuItem();
				m_menuItemReceiptCancel.setText(Constants.CANCEL_RECEIPT);
			}
			return m_menuItemReceiptCancel;
		}

		public JMenuItem getMenuItemReceiptUpdate() {
			if (m_menuItemReceiptUpdate == null) {
				m_menuItemReceiptUpdate = new JMenuItem();
				m_menuItemReceiptUpdate.setText(Constants.UPDATE_RECEIPT);
			}
			return m_menuItemReceiptUpdate;
		}

		public JMenuItem getMenuItemReceiptCreate() {
			if (m_menuItemReceiptCreate == null) {
				m_menuItemReceiptCreate = new JMenuItem();
				m_menuItemReceiptCreate.setText(Constants.CREATE_RECEIPT);
			}
			return m_menuItemReceiptCreate;
		}

		public JMenu getMenuTitleBill() {
			if (m_menuTitleBill == null) {
				m_menuTitleBill = new JMenu();
				m_menuTitleBill.setText(Constants.BILL);
				m_menuTitleBill.add(getMenuItemBillCreate());
				m_menuTitleBill.add(getMenuItemBillUpdate());
				m_menuTitleBill.add(getMenuItemBillCancel());
				m_menuTitleBill.add(getMenuItemBillSearch());
				m_menuTitleBill.add(getMenuItemBillPrint());
			}
			return m_menuTitleBill;
		}

		public JMenuItem getMenuItemBillPrint() {
			if (m_menuItemBillPrint == null) {
				m_menuItemBillPrint = new JMenuItem();
				m_menuItemBillPrint.setText(Constants.PRINT_BILL);
			}
			return m_menuItemBillPrint;
		}

		public JMenuItem getMenuItemBillSearch() {
			if (m_menuItemBillSearch == null) {
				m_menuItemBillSearch = new JMenuItem();
				m_menuItemBillSearch.setText(Constants.SEARCH_BILL);
			}
			return m_menuItemBillSearch;
		}

		public JMenuItem getMenuItemBillCancel() {
			if (m_menuItemBillCancel == null) {
				m_menuItemBillCancel = new JMenuItem();
				m_menuItemBillCancel.setText(Constants.CANCEL_BILL);
			}
			return m_menuItemBillCancel;
		}

		public JMenuItem getMenuItemBillUpdate() {
			if (m_menuItemBillUpdate == null) {
				m_menuItemBillUpdate = new JMenuItem();
				m_menuItemBillUpdate.setText(Constants.UPDATE_BILL);
			}
			return m_menuItemBillUpdate;
		}

		public JMenuItem getMenuItemBillCreate() {
			if (m_menuItemBillCreate == null) {
				m_menuItemBillCreate = new JMenuItem();
				m_menuItemBillCreate.setText(Constants.CREATE_BILL);
                                m_menuItemBillCreate.addActionListener(this);
			}
			return m_menuItemBillCreate;
		}

		public JMenu getMenuTitleVera() {
			if (m_menuTitleVera == null) {
				m_menuTitleVera = new JMenu();
				m_menuTitleVera.setText(Constants.VERA);
				m_menuTitleVera.add(getMenuItemVeraLogOut());
				m_menuTitleVera.add(getMenuItemVeraExit());
			}
			return m_menuTitleVera;
		}

		public JMenuItem getMenuItemVeraExit() {
			if (m_menuItemVeraExit == null) {
				m_menuItemVeraExit = new JMenuItem();
				m_menuItemVeraExit.setText(Constants.EXIT);
			}
			return m_menuItemVeraExit;
		}

		public JMenuItem getMenuItemVeraLogOut() {
			if (m_menuItemVeraLogOut == null) {
				m_menuItemVeraLogOut = new JMenuItem();
				m_menuItemVeraLogOut.setText(Constants.LOGOUT);
			}
			return m_menuItemVeraLogOut;
		}

    public void actionPerformed(ActionEvent e) {
        String actionCommand = e.getActionCommand();
        if (actionCommand.equalsIgnoreCase("Create New Bill")) {
            
//            Window w = (Window) this.getParent().getParent();
//            w.dispose();
//            new BillScreen().setVisible(true);
//            this.getParent().setVisible(false);
//            NewJPanel njp = new NewJPanel();
//            this.getParent().add(njp);
//            njp.setVisible(true);
            System.out.println(this.getParent().toString());
            System.out.println(this.getParent().toString().toString());
        }
    }
    
}
